home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 12 / Amiga Format AFCD12 (Apr 1997, Issue 96).iso / -readerstuff- / manolis_pappas / mathfx / examples / contour.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-29  |  1.0 KB  |  38 lines

  1. /* Demonstration of contour plotting with MathFX library. */
  2. /* Copyright (©) 1995, The Xperts Group Inc. All Rights Reserved. */
  3. /* Author: Manolis S Pappas. */
  4.       
  5. #define NPTS      41
  6.  
  7. float tr[6] = {0.05, 0.0, -1.05, 0.0, 0.05, -1.05};
  8.  
  9. static float clevel[11] = {-1.,-.8,-.6,-.4,-.2,0,.2,.4,.6,.8,1.};
  10.  
  11. static int mark=1500, space=1500;
  12.  
  13. main()
  14. {
  15.       int i, j;
  16.       float xx, yy;
  17.       float z[NPTS][NPTS], w[NPTS][NPTS];
  18.       void xform();
  19.  
  20.       for (i=0; i<NPTS; i++) {
  21.         xx = (double)(i-(NPTS/2))/(double)(NPTS/2);
  22.         for (j=0; j<NPTS; j++)  {
  23.           yy = (double)(j-(NPTS/2))/(double)(NPTS/2) - 1.0;
  24.           z[i][j] = xx*xx - yy*yy;
  25.           w[i][j] = 2*xx*yy;
  26.         }
  27.       }
  28.  
  29.       fxstar(1,1);
  30.       fxenv(-1.0,1.0,-1.0,1.0,0,0);
  31.       fxcont(z,NPTS,NPTS,1,NPTS,1,NPTS,clevel,11,xform);
  32.       fxstyl(1,&mark,&space);
  33.       fxcont(w,NPTS,NPTS,1,NPTS,1,NPTS,clevel,11,xform);
  34.       fxlab("X Coordinate", "Y Coordinate","Contour Plots of Saddle Points");
  35.       fxtext();
  36.       fxend();
  37. }
  38.